package org.pinda.server;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;

public class LoggerFormat extends Formatter {

	@Override
	public String format(LogRecord record) {
		StringBuilder sb = new StringBuilder();
		sb.append("[");
		sb.append(calcDate());
		sb.append("-");
		sb.append(record.getLoggerName());
		sb.append("-");
		sb.append(record.getLevel());
		sb.append("] ");
		sb.append(record.getMessage());
		sb.append(System.lineSeparator());
		return sb.toString();
	}

	private String calcDate() {
		SimpleDateFormat date_format = new SimpleDateFormat("HH:mm:ss");
		Date resultdate = new Date(System.currentTimeMillis());
		return date_format.format(resultdate);
	}

}
